import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path'
import dayjs from 'dayjs'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {NaiveUiResolver} from 'unplugin-vue-components/resolvers'
import tailwindcss from "tailwindcss"
import autoprefixer from "autoprefixer"

const __APP_INFO__ = {
    buildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
};

export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            imports: [
                'vue',
                {
                    'naive-ui': [
                        'useDialog',
                        'useMessage',
                        'useNotification',
                        'useLoadingBar'
                    ]
                }
            ]
        }),
        Components({
            resolvers: [NaiveUiResolver()]
        }),
    ],
    css: {
        postcss: {
            plugins: [
                tailwindcss,
                autoprefixer,
            ]
        }
    },
    build: {
        outDir: 'lib',
        lib: {
            entry: resolve(__dirname, 'src/main.js'),
            name: 'PmMonitoringSdk',
            fileName: 'pm-monitoring-sdk',
        },
    },
    define: {
        'process.env': {},
        __APP_INFO__: JSON.stringify(__APP_INFO__)
    },
    server: {
        host: '0.0.0.0',
        port:'7878'
    }
})
